package main.java.easy;

/**
 * @Author: 郑国荣
 * @Date: 2023-07-23-12:54
 * @Description: 斐波那契数列
 */
public class ClimebStairs {

    public static int counts=0;
    public static int climebStairs(int n){
        int p = 0, q = 0, r = 1;//p q r分别代表第n-2,n-1,n阶台阶的走法
        // 从第三阶开始算起
        for (int i = 1; i <= n; ++i) {
            p = q;
            q = r;
            r = p + q;
        }
        return r;
    }

    public static void main(String[] args) {
        System.out.println(climebStairs(3));
        System.out.println(climebStairs(4));
        System.out.println(climebStairs(5));
        System.out.println(climebStairs(6));
        System.out.println(climebStairs(7));
        System.out.println(climebStairs(8));

    }
}
